import { GETPMMLLIST, GETMODELVERSIONS } from '../../actions/action_types'

/**
 * 模型文件管理
 */
const defaultState = {
    models: [],
    totalSize: 0,
    currentPage: 1,
    predictUrl: ""
}

export const pmmlStateReducer = (state=defaultState, action) => {

    switch (action.type) {
        case GETPMMLLIST:
            return (
                state = {
                    "models": action.data.models,
                    "totalSize": action.data.totalSize,
                    "currentPage": action.data.currentPage,
                    "predictUrl": action.data.predictUrl
                }
            )
        default:
            return state
    }
}

/**
 * 模型版本文件管理
 */
 const defaultVersionState = {
    versions: []
}

export const versionStateReducer = (state=defaultVersionState, action) => {

    switch (action.type) {
        case GETMODELVERSIONS:
            return (
                state = {
                    "versions": action.data
                }
            )
        default:
            return state
    }
}
